import { _decorator, Component, EventHandler, Node, ToggleContainer } from 'cc';
import { UIComponent } from '../../../../Framework/Scripts/Managers/UIComponent';
import GridListView from '../../../../Framework/Scripts/Engine/GridListView';
const { ccclass, property } = _decorator;

/**
 * 主题赛的内容
 */
@ccclass('GameRank4')
export class GameRank4 extends UIComponent {
    girdList: GridListView;
    listData: number[];
    protected onLoad(): void {
        this.InitUI();
    }

    start() {
        this.InitData();
    }

    protected onDestroy(): void {
        this.unRegisterEvent();
    }

    private InitUI(){
        this.registerEvent();

        this.AddButtonListener('btnBack',this,this.OnBtnCloseClick);

        let scrollView = this.ViewNode('bg/ScrollView');
        this.girdList = scrollView.getComponent(GridListView);
    }

    private InitData(){
        this.listData = [1,2,3,4,5,6,7,8];
        
        this.scheduleOnce(()=>{
            this.girdList.reset(this.listData.length);
        })
    }
    
    private registerEvent(){
        // globalThis.gameMgr._eventTarget.on(EventMsgKes.loading,this.onLoadingPro,this);
    }

    private unRegisterEvent(){
        // globalThis.gameMgr._eventTarget.off(EventMsgKes.loading,this.onLoadingPro,this);
    }

    private callback(event: Event, customEventData: string) {
        // 这里 event 是一个 Touch Event 对象，你可以通过 event.target 取到事件的发送节点
        // 这里的 customEventData 参数就等于之前设置的 'foobar'

        console.log('======callback========',event.target);
    }

    public UpdateList4(list: GridListView, pos: number, item: Node){

    }
}

